package cn.zjutleo.village_server.controller;

import cn.zjutleo.village_server.entity.NativeVillage;
import cn.zjutleo.village_server.mapper.NativeVillageMapper;
import cn.zjutleo.village_server.vo.ResponseBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

/**
 * @Author: 张坤
 * @DateTime: 2021/8/30 18:57
 * @Description: 该类用于 TODO
 */
@Api(tags = "村庄信息查询")
@RestController()
public class NativeVillageController {
    @Autowired
    NativeVillageMapper nativeVillageMapper;

    @ApiOperation("模糊查询村庄名称")
    @PostMapping("/api/getVillageInfoFuzzySearch")
    List<NativeVillage> getVillageInfoFuzzySearch(@RequestBody HashMap<String ,String > map){
        String v_name=map.get("v_name");
        return nativeVillageMapper.getVillageInfoFuzzySearch(v_name);
    }

    @ApiOperation("根据id查询村庄信息")
    @GetMapping("/village/{id}")
    public ResponseBean<NativeVillage> getVillageInfoById(@PathVariable(value = "id") Integer id) {
        NativeVillage nativeVillage = nativeVillageMapper.getVillageById(id);
        return new ResponseBean<>(nativeVillage);
    }
}
